import { request } from '@utils/http'
import { IDeparmentList, IDictList, IDoctorList, IDoctorReqParams, IHopsitalListResponse, IHospitalDetailResponse, IHospitalListReqParams, IScheduleReqParams, IScheduleResponse } from "./model/hospitalListTypes";
/**
 * 获取医院列表分页数据
 * @param param0 
 * @returns Promise<IHopsitalListResponse>
 */
export const getHospitalList = async ({
    page,
    limit,
    hoscode,
    hosname,
    hostype,
    provinceCode,
    cityCode,
    districtCode,
    status
}: IHospitalListReqParams) => {
    return request.get<any, IHopsitalListResponse>(`/admin/hosp/hospital/${page}/${limit}`, {
        params: {
            hoscode,
            hosname,
            hostype,
            provinceCode,
            cityCode,
            districtCode,
            status
        }
    })
}

/**
 * 获取省列表
 */

export const getProvinceList = async(param:string='province')=>{
    return request.get<any, IDictList>(`/admin/cmn/dict/findByDictCode/${param}`)
}

/**
 * 根据id 获取市、区列表信息
 */
export const getCityOrDict = async (id:string)=>{
    return request.get<any, IDictList>(`/admin/cmn/dict/findByParentId/${id}`)
}
/**
 * 切换医院上线下状态
 * @param id  
 * @param status 1 上线 0 下线
 * @returns null
 */
export const changeStatus = async (id:string, status:number)=>{
    return request.get<any,null>(`/admin/hosp/hospital/updateStatus/${id}/${status}`)
}

/**
 * 根据id 获取医院详情
 * @param id 
 * @returns Promise<IHospitalDetailResponse>
 */
export const getHospitalDetail = async (id:string)=>{
    return request.get<any, IHospitalDetailResponse>(`/admin/hosp/hospital/show/${id}`)
}

/**
 * 根据hoscode 获取医院科室列表
 * @param hoscode 
 * @returns 
 */
export const getDepartmentList = async (hoscode:string)=>{
    return request.get<any, IDeparmentList>(`/admin/hosp/department/${hoscode}`)
}

/**
 * 获取医院科室排班日期列表
 * @param {page:第几页,limit:每页几条,hoscode:医院编码, depcode:部门编码}
 * @returns Promise<IScheduleResponse>
 */
export const getScheduleList = async ({page,limit,hoscode, depcode}:IScheduleReqParams)=>{
    return request.get<any, IScheduleResponse>(`/admin/hosp/schedule/getScheduleRule/${page}/${limit}/${hoscode}/${depcode}`)
}

/**
 * 获取排班医生列表
 * @param  hoscode:医院编码, depcode 科室编号, workDate 排班日期
 * @returns Promise<IDoctorList>
 */
export const getDoctorList = async ({hoscode, depcode, workDate}:IDoctorReqParams)=>{
    return request.get<any, IDoctorList>(`/admin/hosp/schedule/findScheduleList/${hoscode}/${depcode}/${workDate}`)
}